extends Talent
var utils = globalData.infoDs["g_AneHekUtils"]
var base = globalData.infoDs["g_AneHekBase"]
func init():
	name = "铸币发家"
var flag = 1
var cha = null
var cnt = 0
var cntlimt = 50
var txt = "战斗开始后，每秒获得2金币[上限随难度增加而增加]\n此天赋不需要升级"
func _connect():
	sys.main.connect("onBattleStart", self, "run")
	sys.main.connect("onBattleEnd",self,"changeflag")
	var diff = int(base.getSetting("difficult",1))
	cntlimt += int(diff/5) * 10
	txt = "战斗开始后，每秒获得2金币[上限随难度增加而增加]\n" + "当前上限：%d"%int(cntlimt) +  "\n此天赋不需要升级"

func run():
	flag = 1
	cha = null
	cnt = 0
	var chas = utils.getAllChas(2)
	for i in chas:
		if i.has_method("_upS"):
			i.connect("upS",self,"run2")
			cha = i
			break

func run2():
	if flag:
		sys.main.player.plusGold(2)
		cnt += 2
	if cnt == cntlimt:
		changeflag()
		
func changeflag():
	flag = 0
	cha.disconnect("upS",self,"run2")
	
func get_info():
	return txt